import request from '@/utils/request'

// 配送路线列表
export function listDeliveryRoutes(query) {
  return request({
    url: '/delivery-route/page',
    method: 'get',
    params: query
  })
}

// 获取所有可用配送路线
export function listAllDeliveryRoutes() {
  return request({
    url: '/delivery-route/list',
    method: 'get'
  })
}

// 获取配送路线详情
export function getDeliveryRoute(id) {
  return request({
    url: `/delivery-route/${id}`,
    method: 'get'
  })
}

// 根据团长ID获取路线信息
export function getRouteByLeaderId(leaderId) {
  return request({
    url: `/delivery-route/by-leader/${leaderId}`,
    method: 'get'
  })
}

// 新增配送路线
export function addDeliveryRoute(data) {
  return request({
    url: '/delivery-route',
    method: 'post',
    data: data
  })
}

// 修改配送路线
export function updateDeliveryRoute(data) {
  return request({
    url: '/delivery-route',
    method: 'put',
    data: data
  })
}

// 删除配送路线
export function deleteDeliveryRoute(id) {
  return request({
    url: `/delivery-route/${id}`,
    method: 'delete'
  })
}

// 更新配送路线状态
export function changeDeliveryRouteStatus(id, status) {
  return request({
    url: '/delivery-route/status',
    method: 'put',
    params: {
      id,
      status
    }
  })
}

// 获取可用的团长列表
export function getAvailableLeaders() {
  return request({
    url: '/delivery-route/available-leaders',
    method: 'get'
  })
} 